package com.mall.server.service;

import com.mall.autoconfig.template.OssTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;

@Service
public class OssService {

    @Autowired
    private OssTemplate ossTemplate;

    public String ossLogo(MultipartFile photoFile) {

        String imageUrl = null;
        try {
            //将图片上传到百度云，oss参数：文件名，文件输入流
            imageUrl = ossTemplate.upload(photoFile.getOriginalFilename(), photoFile.getInputStream());
        } catch (IOException e) {
            e.printStackTrace();
        }
        return imageUrl;
    }

}
